package com.xinzhidi.web.controlset.controller;

import com.xinzhidi.common.annotation.Log;
import com.xinzhidi.common.core.controller.BaseController;
import com.xinzhidi.common.core.domain.AjaxResult;
import com.xinzhidi.common.enums.BusinessType;
import com.xinzhidi.web.controlset.domain.dto.ControlSetDto;
import com.xinzhidi.web.controlset.domain.po.ControlSetPo;
import com.xinzhidi.web.controlset.domain.vo.ControlSetListVo;
import com.xinzhidi.web.controlset.service.ControlSetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 平衡调控数据设置Controller
 *
 * @author cx
 * @date 2023-06-27
 */
@RestController
@Api(tags = "平衡调控数据设置")
@RequestMapping("/controlSet")
@RequiredArgsConstructor
public class ControlSetController extends BaseController {

    @Autowired
    private ControlSetService setService;

    @ApiOperation("查询平衡调控数据设置详情")
    @PostMapping("/getDataSetInfo")
    public ControlSetListVo getDataSetInfo(@Validated @RequestBody ControlSetPo po) {
        return setService.getControlSetInfo(po);

    }

    @ApiOperation("新增或修改调控")
    @Log(title = "新增数据设置", businessType = BusinessType.INSERT)
    @PostMapping("addOrUpdateControlSet")
    public AjaxResult addDataSet(@Validated @RequestBody ControlSetDto dto) {
        return toAjax(setService.insertControlSet(dto));
    }

    @ApiOperation("批量调控")
    @Log(title = "新增数据设置", businessType = BusinessType.INSERT)
    @PostMapping("batchControlSet")
    public AjaxResult batchControlSet(@Validated @RequestBody List<ControlSetDto> dtoList) {
        return toAjax(setService.batchControlSet(dtoList  ,"2"));
    }

    @ApiOperation("一键调控")
    @PostMapping("oneKeyRegulation")
    public AjaxResult oneKeyRegulation(@Validated @RequestBody ControlSetPo po) {
        return toAjax(setService.oneKeyRegulation(po));
    }

}
